﻿// Inner Fire 游戏引擎库
// UI - 图片
//
// Copyright (c) 2025 by 尔西大帝. All rights reserved.
//
// 用于UI的组件-图片
// 显示一个图片
//
// Author: 尔西大帝
// Email: 2670613871@qq.com
// Created: 2025-01-07

#pragma once

#include <ui/component/ui_component.h>
#include <static_string.h>
#include <ui/prefab/image_info.h>

namespace ifire::ui {

class Image : public UIComponent {
public:
  Image() = default;
  Image(ikit::sstr name_id, const ImageInfo* info);
  Image(const Image& lhs) = delete;
  Image& operator=(const Image& lhs) = delete;
  ~Image() = default;

  const ImageInfo* Info() const { return info_; }
  inline void SetImage(dx::DxImage* img) { image_ = img; }
  void SetImage(const char* img_name);
  void SetPosition(XMFLOAT2 position);

  void SetVisible(bool state) override;
  void SetScale(XMFLOAT2 scale) override;
  void SetRefresh() override;
private:
  const ImageInfo* info_;
  dx::DxImage* image_ = nullptr;
};

using ImagePtr = std::unique_ptr<Image>;

} // namespace ifire::ui